import { uniqueId } from "lodash-es";

export type TMenu = {
  id?: number | string;
  name: string;
  path: string;
  icon?: string;
  title: string;
  redirect?: string; // 重定向目标
  component?: string; // 组件路径
  hidden?: boolean; // 是否在菜单处隐藏
  children?: TMenu[];
  parentRoute?: TMenu;

  props?: boolean; // 是否把动态路由参数设置为prop
  isTopPage?: boolean; // 顶级页面，即与登录页面是平级页面
  keepAlive?: boolean;
  disableTab?: boolean; // 开启后，不会在tab栏显示
  autoDestroyTab?: boolean; // 离开该页后，自动移除Tab

  type: "path" | "name";
};

const menu = [
  // {
  //   name: "Home",
  //   icon: "Odometer",
  //   title: "运营看板",
  //   path: "/home",
  //   component: "views/home/dashboard.vue",
  // },

  // {
  //   name: "Vip",
  //   icon: "Medal",
  //   title: "会员管理",
  //   path: "/vip/list",
  //   component: "views/vip/list.vue",
  // },

  // {
  //   name: "Supplier",
  //   icon: "Shop",
  //   title: "供应商",
  //   path: "/supplier/list",
  //   component: "views/supplier/list.vue",
  // },

  // {
  //   name: "Users",
  //   icon: "UserFilled",
  //   title: "用户",
  //   path: "/users/list",
  //   component: "views/users/list.vue",
  // },
  // {
  //   name: "SystemUser",
  //   icon: "Avatar",
  //   title: "管理员",
  //   path: "/system/user/list",
  //   component: "views/system/users/list.vue",
  // },

  {
    name: "ActivityManage",
    icon: "Present",
    title: "活动管理",
    path: "/activity",
    children: [
      {
        name: "ActivityList",
        title: "活动列表",
        path: "/activity/list",
        component: "views/activity/list.vue",
      },
      {
        name: "ActivityCreate",
        title: "添加活动",
        path: "/activity/create",
        component: "views/activity/activityModify.vue",
        hidden: true,
        parentRoute: {
          name: "ActivityList",
          title: "活动列表",
          path: "/activity/list",
        },
      },
      {
        name: "ActivityModify",
        title: "编辑活动",
        path: "/activity/modify/:id",
        component: "views/activity/activityModify.vue",
        hidden: true,
        parentRoute: {
          name: "ActivityList",
          title: "活动列表",
          path: "/activity/list",
        },
      },
      {
        name: "ActivityStall",
        title: "活动展位",
        path: "/activity/stall/list/:id",
        component: "views/activity/stallList.vue",
        hidden: true,
      },
      {
        name: "ExamineEnroll",
        title: "活动商户",
        path: "/activity/enroll/list",
        component: "views/examine/enroll/list.vue",
        hidden: true,
      },
      {
        name: "ExamineEnrollDetail",
        title: "活动商户详情",
        path: "/activity/enroll/detail/:id",
        component: "views/examine/enroll/detail.vue",
        hidden: true,
      },
      {
        name: "EnrollModify",
        title: "编辑活动商户",
        path: "/activity/enroll/modify/:id",
        component: "views/examine/enroll/enrollModify.vue",
        hidden: true,
      },
      {
        name: "ActivityTicketList",
        title: "权益包列表",
        path: "/activity/ticket/list/:act_id",
        component: "views/activity/ticketList.vue",
        hidden: true,
      },
      {
        name: "ActivityTicketCreate",
        title: "新增权益包",
        path: "/activity/ticket/:act_id/create",
        component: "views/activity/ticketModify.vue",
        hidden: true,
      },
      {
        name: "ActivityTicketModify",
        title: "修改权益包",
        path: "/activity/ticket/:act_id/modify/:id",
        component: "views/activity/ticketModify.vue",
        hidden: true,
      },

      {
        name: "ActivitySpecList",
        title: "规格管理",
        path: "/activity/spec/list",
        component: "views/activity/specList.vue",
      },

      {
        name: "ActivityEtimeList",
        title: "活动场次",
        path: "/activity/etime/list/:act_id",
        component: "views/activity/etimeList.vue",
        hidden: true,
      },

      {
        name: "ActivityPackageList",
        title: "权益模板",
        path: "/activity/package/list",
        component: "views/activity/packageList.vue",
      },

      {
        name: "ActivityPackageModify",
        title: "编辑权益模板",
        path: "/activity/package/modify/:id",
        component: "views/activity/packageModify.vue",
        hidden: true,
      },
      {
        name: "ActivityPackageCreate",
        title: "新增权益模板",
        path: "/activity/package/create",
        component: "views/activity/packageModify.vue",
        hidden: true,
      },
      {
        name: "ActivityGiftList",
        title: "赠票列表",
        path: "/activity/gift/list/:actId",
        component: "views/activity/gift/list.vue",
        hidden: true,
      },
      {
        name: "ActivityGiftDetailList",
        title: "赠票详情",
        path: "/activity/gift/list/:actId/detail/:id",
        component: "views/activity/gift/detail.vue",
        hidden: true,
      },

      // {
      //   name: "SponsorList",
      //   title: "主办方列表",
      //   path: "/sponsor/list",
      //   component: "views/activity/sponsorList.vue",
      // },
    ],
  },

  {
    name: "Order",
    icon: "Discount",
    title: "订单管理",
    path: "/order",
    children: [
      {
        name: "DepositOrderList",
        title: "押金订单",
        path: "/order/depositList",
        component: "views/order/depositList.vue",
      },
      {
        name: "ChargeOrderList",
        title: "收款订单",
        path: "/order/chargeList",
        component: "views/order/chargeList.vue",
      },
      {
        name: "TicketOrderList",
        title: "售票订单",
        path: "/order/ticketList",
        component: "views/order/ticketList.vue",
      },
      {
        name: "OrderCouponList",
        title: "票券管理",
        path: "/order/coupon/list",
        component: "views/order/couponList.vue",
      },
      {
        name: "OrderCouponDetail",
        title: "票券详情",
        path: "/order/coupon/detail/:sn",
        component: "views/order/couponDetail.vue",
        hidden: true,
      },
    ],
  },
  {
    name: "MerchantManage",
    icon: "CoffeeCup",
    title: "商户管理",
    path: "/merchant",
    // 表示审核通过 ，audit_status
    auth: true,
    children: [
      {
        name: "MerchantList",
        title: "商户列表",
        path: "/merchant/list",
        component: "views/merchant/list.vue",
      },
      {
        name: "MerchantDetail",
        title: "商家详情",
        path: "/merchant/:id",
        component: "views/merchant/detail.vue",
        hidden: true,
      },
      {
        name: "ExamineSettled",
        title: "商家审核",
        path: "/examine/settled/list",
        component: "views/examine/settled/list.vue",
      },
      {
        name: "MerchantStaffList",
        title: "职工管理",
        path: "/merchant/:id/staff/list",
        component: "views/merchant/staffList.vue",
        hidden: true,
      },
    ],
  },
  {
    name: "CouponManage",
    icon: "Tickets",
    title: "优惠券管理",
    redirect: "/coupon/list",
    children: [
      {
        name: "CouponList",
        title: "优惠券列表",
        path: "/coupon/list",
        component: "views/coupon/couponList.vue",
      },
      {
        name: "CouponManageCreate",
        title: "新增票券",
        path: "/coupon/create",
        component: "views/coupon/couponModify.vue",
        hidden: true,
      },
      {
        name: "CouponManageModify",
        title: "编辑票券",
        path: "/coupon/modify/:id",
        component: "views/coupon/couponModify.vue",
        hidden: true,
      },
      {
        name: "CouponManageRules",
        title: "编辑票券规则",
        path: "/coupon/rules/:id",
        component: "views/coupon/couponRules.vue",
        hidden: true,
      },
    ],
  },
  {
    name: "Content",
    icon: "Document",
    title: "内容管理",
    path: "/content/list",
    children: [
      {
        name: "AgreementList",
        title: "协议介绍",
        path: "/content/agreement-list",
        component: "views/content/agreementList.vue",
      },
      {
        name: "CarouselList",
        title: "轮播图",
        path: "/content/carousel-list",
        component: "views/content/carouselLists.vue",
      },
    ],
  },
  {
    name: "SystemUserAccount",
    icon: "Avatar",
    title: "个人中心",
    path: "/system/account",
    component: "views/system/account/index.vue",
    hidden: true,
  },
  {
    name: "SystemTools",
    icon: "Tools",
    title: "工具",
    path: "/tool",
    children: [
      {
        name: "ToolsUrlLink",
        title: "小程序链接",
        path: "/tools/urllink",
        component: "views/tools/urlLink.vue",
      },
    ],
  },

  // {
  //   name: "AccountManage",
  //   icon: "User",
  //   title: "账户管理",
  //   path: "/account",
  //   children: [
  //     {
  //       name: "AccountInfo",
  //       path: "/account/info",
  //       title: "账号信息",
  //       component: "views/account/info.vue",
  //     },

  //     {
  //       name: "AcccountCertification",
  //       path: "/account/certification",
  //       title: "入驻认证",
  //       component: "views/account/certification.vue",
  //     },
  //   ],
  // },
] as TMenu[];

function setID(list: TMenu[]) {
  list.forEach((item) => {
    item.id = uniqueId();

    if (item.children) {
      setID(item.children);
    }
  });
}

setID(menu);
export default menu;
